import { useDetail, useList } from "@/hooks";
import { getUserInfoUrl } from "@/command/apiTool";
import { getAction, postAction } from "@/command/netTool";
import * as vant from "vant";
const { showFailToast, showSuccessToast } = vant;
import { useRouter } from "vue-router";
export const useRequest = () => {
  const router = useRouter();
  const [farmInfo] = useDetail(
    getUserInfoUrl({
      dh: "/api/H5/richMeansOfAgriculturalProduction/large/edit",
      xh: "",
    }),
    {
      productList: [],
    }
  );
  const confirm = (params: any) => {
    console.log("eee", params);
    let queryParams = {
      idList: params.productList,
    };
    postAction(
      "/api/H5/richMeansOfAgriculturalProduction/large/saveAgricultural",
      { ...queryParams },
      { isResolve: true }
    ).then((e) => {
      showSuccessToast(e.msg || e.data);
      setTimeout(() => {
        router.back();
      }, 200);
    });
  };
  return {
    confirm,
    farmInfo,
  };
};
